package com.acme.bankapp.domain.bank.account;

import com.acme.bankapp.domain.bank.exception.NotEnoughFundsException;

/**
 * This class implements {@link AbstractAccount} interface for usual clients (without overdraft)
 *
 * @author Alexander Kotov
 */

public class SavingAccount extends AbstractAccount {

    public SavingAccount(double balance) throws IllegalArgumentException{
        super(balance);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void withdraw(double amount) throws NotEnoughFundsException{
        if (balance >= amount) {
            balance -= amount;
        }
        else {
            throw new NotEnoughFundsException(this);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public double getMaximumAmountToWithdraw() {
        return balance;
    }
}
